home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java Developer's Companion
/
Java Developer's Companion.iso
/
Javacup
/
IN231VFD.TAR
/
internet
/
IN231VFD
/
Sound.java
< prev
next >
Wrap
Text File
|
1996-05-21
|
1KB
|
42 lines
// Sound.java - Sound support
//
// Copyright (C) 1996 by Dale Gass
// Non-exclusive license granted to MKS, Inc.
//
import java.lang.*;
import java.util.*;
import java.awt.*;
import java.net.*;
import java.applet.*;
// Sound - Object for representing, playing sounds
public class Sound {
static Applet app; // Parent applet
static String files[] = { // The sounds we use
"doh.au", "drip.au", "out.au", "hey.au"
};
public final static int doh = 0; // Constants names for the sounds
public final static int drip = 1;
public final static int out = 2;
public final static int hey = 3;
static AudioClip sounds[]; // Loaded sounds stored here
// Preload audio
public static void init(Applet a) {
app = a;
URL url = app.getCodeBase();
sounds = new AudioClip[files.length];
for (int i=0; i<files.length; i++)
sounds[i] = app.getAudioClip(url, files[i]);
}
// Constructor - Play the appropriate sound
public Sound(int which) {
sounds[which].play();
}
}